package com.app.controller;


import cn.dev33.satoken.stp.StpUtil;
import com.app.common.TotalConfig;
import com.app.pojo.GasDetails;
import com.app.service.IGasDetailsService;
import com.app.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户信息表 前端控制器
 * </p>
 *
 * @author yoominic
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/personnelInformation")
@Api(tags = "admin用户信息account接口")
public class PersonnelInformationController {
    //------------------------------------------------------------------------------------
    //由于表结构调整，当前数据全从gasDetails中查，数据也更新到这里面gasDetails
    //------------------------------------------------------------------------------------
    @Autowired
    private IGasDetailsService gasDetailsService;


    @GetMapping("/list")
    @ApiOperation(value = "列表查询")
    public Result<List<GasDetails>> listPersonnelInformation(Integer page,Integer limit,String keyword) {
        return gasDetailsService.listPersonnelInformation(page,limit,keyword);
    }

    @ApiOperation(value = "删除")
    @GetMapping("/delete")
    public Result deletePersonnelInformation(Integer id) {
        if (!StpUtil.hasPermission("admin:equipment:delete")){
            return Result.error(TotalConfig.NO_PERMISSION);
        }
        return gasDetailsService.deletePersonnelInformation(id);
    }


    @ApiOperation(value = "详情")
    @GetMapping("/detail")
    public Result<GasDetails> detailPersonnelInformation(Integer id) {
        return Result.success(gasDetailsService.getById(id));
    }

    @ApiOperation(value = "修改和新增")
    @PostMapping("/update")
    public Result addAndUpdatePersonnelInformation(@RequestBody GasDetails gasDetails) {
        return gasDetailsService.addAndUpdatePersonnelInformation(gasDetails);
    }
}

